package org.com.wlc.jdkproxy;

import org.com.wlc.proxy.Marry;
import org.com.wlc.proxy.Me;
import org.com.wlc.proxy.MeRent;
import org.com.wlc.proxy.RentHouse;

/**
 * @author 王立朝
 * @description
 * @date 2021-11-28 10:04:04
 */
public class JdkHandlerTest {


    public static void main(String[] args) {
        //System.getProperties().put("sun.misc.ProxyGenerator.saveGeneratedFiles","true");可以生成代理的
        //class文件
        System.getProperties().put("sun.misc.ProxyGenerator.saveGeneratedFiles", "true");
        // 目标对象
        Me me = new Me();
        // jdk代理类
        JdkHandler jdkHandler = new JdkHandler(me);
        // 获取jdk代理对象
        Marry marry = (Marry) jdkHandler.getProxy();
        marry.marry();
        System.out.println("marry.marry2() = " + marry.marry2());

        //MeRent meRent = new MeRent();
        //JdkHandler jdkHandler1= new JdkHandler(meRent);
        //RentHouse rentHouse = (RentHouse) jdkHandler1.getProxy();
        //rentHouse.rentHouse();


    }
}
